package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.baseplatform.domain.bo.HomeRecommendTypeBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.HomeRecommendType;
import com.ltkj.baseplatform.service.IHomeRecommendTypeService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 综合推荐分类Controller
 * 
 * @author liupf
 * @date 2023-09-01
 */
@Api(tags = "综合推荐分类")
@RestController
@RequestMapping("/recommendtype")
public class HomeRecommendTypeController extends BaseController
{
    @Autowired
    private IHomeRecommendTypeService homeRecommendTypeService;

    /**
     * 查询综合推荐分类列表
     */
    @ApiOperation("查询综合推荐分类列表")
    @RequiresPermissions("baseplatform:recommendtype:list")
    @GetMapping("/list")
    public TableDataInfo list(HomeRecommendType homeRecommendType)
    {
        startPage();
        List<HomeRecommendType> list = homeRecommendTypeService.selectHomeRecommendTypeList(homeRecommendType);
        return getDataTable(list);
    }

    /**
     * 查询栏目树
     */
    @RequiresPermissions("baseplatform:recommendtype:list")
    @GetMapping(value = "/tree")
    @ApiOperation("查询综合推荐树")
    public AjaxResult channelTree()
    {
        return AjaxResult.success(homeRecommendTypeService.selectRecommendTreeList());
    }


    /**
     * 导出综合推荐分类列表
     */
    /*@ApiOperation("导出综合推荐分类列表")
    @RequiresPermissions("baseplatform:recommendtype:export")
    @Log(title = "综合推荐分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeRecommendType homeRecommendType)
    {
        List<HomeRecommendType> list = homeRecommendTypeService.selectHomeRecommendTypeList(homeRecommendType);
        ExcelUtil<HomeRecommendType> util = new ExcelUtil<HomeRecommendType>(HomeRecommendType.class);
        util.exportExcel(response, list, "综合推荐分类数据");
    }*/

    /**
     * 获取综合推荐分类详细信息
     */
    @ApiOperation("获取综合推荐分类详细信息")
    @RequiresPermissions("baseplatform:recommendtype:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(homeRecommendTypeService.selectHomeRecommendTypeById(id));
    }

    /**
     * 新增综合推荐分类
     */
    @ApiOperation("新增综合推荐分类")
    @RequiresPermissions("baseplatform:recommendtype:add")
    @Log(title = "综合推荐分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody HomeRecommendTypeBo homeRecommendTypeBo)
    {
        return toAjax(homeRecommendTypeService.insertHomeRecommendType(homeRecommendTypeBo));
    }

    /**
     * 修改综合推荐分类
     */
    @ApiOperation("修改综合推荐分类")
    @RequiresPermissions("baseplatform:recommendtype:edit")
    @Log(title = "综合推荐分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody HomeRecommendTypeBo homeRecommendTypeBo)
    {
        return toAjax(homeRecommendTypeService.updateHomeRecommendType(homeRecommendTypeBo));
    }

    /**
     * 删除综合推荐分类
     */
    @ApiOperation("删除综合推荐分类")
    @RequiresPermissions("baseplatform:recommendtype:remove")
    @Log(title = "综合推荐分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(homeRecommendTypeService.deleteHomeRecommendTypeByIds(ids));
    }
}
